
<div id="results">

    <div class="page_navigation" id="fix_top_pager_nav"></div>

    <div class="box clearfix pager_hold" id="pager_hold">

        <div class="col">

            <label>Sort by</label>

            <select name="sort_by" id="sort_by" class="dropdownized">
                <option value="recommended">Recommended</option>
                <? if (!isset($_GET['preview'])): ?>
                        <option value="price">Price</option>
                    <? endif; ?>
                <option value="number_of_stars">Number of stars</option>
                <!--<option value="object_name">Name</option>-->
            </select>

        </div>

    </div>

    <ul class="list hotels-list" id="list">
        <?
            if (!isset($_GET['preview'])) {

                $build_G = $_GET;
                if ($build_G['dest_hot'] == "")
                    $build_G['dest_hot'] = -1;

                unset($build_G['lang']);

                $build_GET = http_build_query($build_G);

                $price_for_no_days = calculateDays($_GET['check_in'], $_GET['check_out'], TRUE);

                $night_s = $price_for_no_days > 1 ? lang('res.nights') : lang('res.night');
            }else {
                $build_GET = '&preview=1';
            }


            $cnt = count($objects);
            for ($i = 0; $i < $cnt; $i++):
                $obj_name = URLify::filter($objects[$i]->object_name);

                $href = lang_url('accommodation/' . $obj_name . '-' . $objects[$i]->object_ID . '?' . $build_GET . '&room_id=' . $objects[$i]->rooms[0]->room_ID);

                $thumbnail = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photo_path . '/thumb_157x123/' . $objects[$i]->photo_name;
                $preview = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photo_path . '/thumb_454x340/' . $objects[$i]->photo_name;


                $thumbnail2 = $thumbnail3 = base_url() . 'assets/img/camera-icon.png';
                $preview2 = $preview3 = base_url() . 'assets/img/camera-icon.png';

                if (isset($objects[$i]->photos[1])):
                    $thumbnail2 = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photos[1]->path . '/thumb_88x88/' . $objects[$i]->photos[1]->photo_name;
                    $preview2 = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photos[1]->path . '/thumb_454x340/' . $objects[$i]->photos[1]->photo_name;

                endif;
                if (isset($objects[$i]->photos[2])):
                    $thumbnail3 = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photos[2]->path . '/thumb_88x88/' . $objects[$i]->photos[2]->photo_name;
                    $preview3 = HOST_URL_HOTELS . 'gallery/' . $objects[$i]->photos[2]->path . '/thumb_454x340/' . $objects[$i]->photos[2]->photo_name;

                endif;

                $stars = (int) $objects[$i]->object_number_of_stars;
                ?>

                <li class="js_item box" id="box-<?= $objects[$i]->object_ID ?>" style="display: block" data-id="<?= $objects[$i]->object_ID ?>">

                    <div class="title">

                        <h2> 
                            <? if ($stars > 0): ?>
                                <div class="stars small black star-<?= $stars ?>"></div>
                            <? endif; ?>
                            <a href="<?= $href ?>"><?= $objects[$i]->object_name ?> - <?= $results[$i]->destination_name ?></a>


                            <? if (isset($results[$i]->object_recommended) && $results[$i]->object_recommended == '1'): ?>
                                <div class="recomended">Recommended</div>
                            <? endif; ?>

                            <? if (isset($results[$i]->object_x_coordinate) && $results[$i]->object_x_coordinate != "" && isset($results[$i]->object_y_coordinate) && $results[$i]->object_y_coordinate != ""): ?>
                                <a href='javascript:' class="show_map" data-id="<?= $results[$i]->object_ID ?>">Show on map</a>
                            <? endif; ?>

                        </h2>

                    </div>

                    <div class="clearfix holder">

                        <div class="colage clearfix">

                            <a class="HoverImg" href="<?= $href ?>" data-id="<?= $preview ?>">
                                <img src="<?= $thumbnail ?>" alt="<?= $objects[$i]->object_name ?>" width="170" height="127"> 
                            </a>
                            <div class="">
                                <a class="HoverImg" href="<?= $href ?>" data-id="<?= $preview2 ?>">
                                    <img src="<?= $thumbnail2 ?>" alt="<?= $objects[$i]->object_name ?>" width="82" height="61"> 
                                </a>
                                <a class="HoverImg" href="<?= $href ?>" data-id="<?= $preview3 ?>">
                                    <img src="<?= $thumbnail3 ?>" alt="<?= $objects[$i]->object_name ?>" width="82" height="61"> 

                                </a>
                            </div>

                        </div>


                        <div class="details">

                            <div class="right">

                                <div class="result-price"><span class="from"><?= lang('from'); ?></span> <?= !isset($_GET['preview']) ? $results[$i]->rooms[0]->selling_price : $results[$i]->lowest_price; ?> <?= currency_sign() ?> </div>
                                <br>
                                <a href="<?= $href ?>" class="button small">Make inquiry</a>

                            </div>
                            <? if (isset($results[$i]->object_distance_from_the_sea) && $results[$i]->object_distance_from_the_sea != ""): ?>
                                <p class="small-desc">Beach: <?= $results[$i]->object_distance_from_the_sea ?>m</p>
                            <? endif; ?>
                            <? if (isset($results[$i]->object_distance_from_the_center) && $results[$i]->object_distance_from_the_center != ""): ?>
                                <p class="small-desc">Center: <?= $results[$i]->object_distance_from_the_center ?>m</p>
                            <? endif; ?>
                            <br>
                            <p class="small-desc">
                                <?= limit_text($results[$i]->object_info, 130, TRUE, TRUE); ?>
                            </p>



                        </div>

                    </div>

                    <div class="table-holder" style="display: block">

                        <div class="header"><?= lang('res.total_price'); ?></div>

                        <table class="table table-condensed table-hover rooms" id="hor-minimalist-b">
                            <tbody>
                                <tr>
                                    <th><?= lang('res.accommodation'); ?></th>
                                    <th><?= lang('res.service'); ?></th>
                                    <th>Status</th>

                                    <th><?= lang('res.total_price'); ?></th>
                                </tr>
                                <?
                                foreach ($results[$i]->rooms as $room):
                                    $href_room = lang_url('accommodation/' . $obj_name . '-' . $results[$i]->object_ID . '?' . $build_GET . '&room_id=' . $room->room_ID);
                                    $person_s = $room->room_max_person > 1 ? lang('res.persons') : lang('res.person');

                                    if ($this->lang->mci_current() == 'me'):

                                        if ($room->room_max_person == 1)
                                            $person_s = lang('res.person');
                                        else if ($room->room_max_person >= 2 && $room->room_max_person <= 4)
                                            $person_s = lang('res.persone');
                                        else
                                            $person_s = lang('res.persons');

                                    endif;

                                    /*                        $this->firephp->log('room.'.underscore($room->room_type_name)); */
                                    ?>
                                    <tr>
                                        <td><a href="<?= $href_room ?>"><?= lang('room.' . underscore($room->room_type_name)); ?> <span class="gray"><?= $room->room_description ?></span>&nbsp;<?= lang('form.for'); ?> <?= $room->room_max_person ?> <?= $person_s ?></a></td>
                                        <td class="gray"><?= $room->service_name ?></td>

                                        <?
                                        switch ($room->room_selling_type_ID) {
                                            case 1:
                                                ?>
                                                <td class="request">
                                                    <!--<a href="<?= $href_room ?>"></a>-->
                                                    <!--<a class="" href="<?= $href_room ?>"><?= lang('res.send_request'); ?></a>-->
                                                    On request
                                                </td>
                                                <?
                                                break;

                                            case 2:
                                                ?><td class="realtime">
                                                    <!--<a class="" href="<?= $href_room ?>"><?= lang('res.book_now'); ?></a>-->
                                                    Available
                                                </td><?
                                                break;
                                        };
                                        ?>
                                        <td class="price"><? if (!isset($_GET['preview'])) echo $room->selling_total . currency_sign(); ?> </td>



                                    </tr>
                                <? endforeach; ?>

                            </tbody>
                        </table>

                    </div>

                </li>

                <?
            endfor;
        ?>
    </ul>

    <div class="box clearfix pager_hold">
        <div class="page_navigation clearfix"></div>
    </div>
</div>